#pragma once

#include "fpqthread_global.h"
#include <QWeakPointer>
#include <QObject>

using FpVoidFunc = std::function<void()>;

class FpQThreadWorker;

class FPQTHREAD_EXPORT FpQThread : public QObject
{
    Q_OBJECT
public:
    FpQThread(QObject *parent = nullptr);
    ~FpQThread();

    void InvokeFn(QObject* obj, const QString& fn);
    void InvokeFn(QObject* obj, const QString& fn, const QVariantList& params);

	void invokeFn(FpVoidFunc fn);
	void blockingInvokeFn(FpVoidFunc fn,int interval = 1);

private:
    void Init();

private:
    class FpQThreadAssistant;
    QWeakPointer<FpQThreadAssistant> _assist;
};
